<template>
  <div style="padding: 40px 20px 40px 0">
    <div style="width: 100%;background-color: #ffffff;height: 80vh;">
		<div style="padding: 15px;">
			<el-form :inline="true" :model="formInline" class="demo-form-inline" label-width="100px">
			  <el-form-item label="提现状态">
			    <el-select v-model="formInline.status" style="width: 150px;">
			      <el-option label="全部" value=""></el-option>
			      <el-option label="处理中" value="P"></el-option>
			      <el-option label="成功" value="TRANSFER_SUCCESS"></el-option>
			    </el-select>
			  </el-form-item>
			  <el-form-item label="时间:">
			  	<el-date-picker type="date" placeholder="开始时间" v-model="startTime" style="width:180px;"></el-date-picker>
			  	到
			  	<el-date-picker type="date" placeholder="结束时间" v-model="endTime" style="width:180px;"></el-date-picker>
			  </el-form-item>
			  <el-button type="primary" @click="fetchData(1)">查询</el-button>
			</el-form>
			
		</div>
		<div style="background-color: #FFFFFF;padding: 15px;">
			<el-table
			  :data="pageInfo.dtos"
			  v-loading="table_loading"
			  element-table_loading-text="加载中"
			  style="width: 100%;"
			  stripe>
			  <el-table-column
			    label="平台订单号"
			    prop='outTradeNo'>
			  </el-table-column>
			
			  <el-table-column
			    width="150"
			    label="出款账号" prop='payerIdentity'>
			  </el-table-column>
			  <el-table-column
			    width="150"
			    label="入款账号" prop='payeeIdentity'>
			  </el-table-column>
			  <el-table-column
			    width="200"
			    label="银行卡名称"
			    prop='cardName'>
			  </el-table-column>
			  <el-table-column
			    label="提现金额"
			    width="100"
			    prop='transferAmount'>
			  </el-table-column>
			  <el-table-column
			    width="150"
			    label="提现时间"
			    prop='orderTime'>
			  </el-table-column>
			  <el-table-column
			    width="150"
			    label="回调时间"
			    prop='backTime'>
			  </el-table-column>
			  <el-table-column
			    width="100"
			    label="失败原因"
			    prop='failReason'>
			  </el-table-column>
<!-- 			  <el-table-column
			    label="系统手续费"
			    width="120"
			    prop='transferSysAmount'>
			  </el-table-column> -->
			 
			  <el-table-column
			    width="100"
			    label="转账状态"
			  >
			    <template scope="scope">
			      <span v-if="scope.row.status == 'P'">处理中</span>
			      <span v-else-if="scope.row.status == 'F' || scope.row.status == 'TRANSFER_FAIL'">失败</span>
			      <span v-else>成功</span>
			    </template>
			  </el-table-column>
			</el-table>
			<div class="paginate">
			  <el-pagination
			    @current-change="handleCurrentChange"
			    :current-page="pageInfo.pageNum"
			    :page-size="pageInfo.pageSize"
			    layout="total, prev, pager, next, jumper"
			    :total="pageInfo.count">
			  </el-pagination>
			</div>
		</div>
      
    </div>
  </div>
</template>

<script>
export default {
  name: "cashList",
  data() {
    return {
      table_loading: true,
      formInline: {
		userId: '',
        pageNum: 1,
		pageSize: 10,
		storeId: '',
		status: '',
		orderTimeStart: '',
		ordreTimeEnd: '',
		storeName: ''
      },
	  startTime: '',
	  endTime: '',
      pageInfo: {
        pageNum: 1,
        pageSize:10,
        count: 1,
        dtos: []
      },
	  CashStat: {
		  inAmt: 0,
		  outAmt: 0,
		  lastAmt: 0
	  }
    }
  },
  mounted() {
    let vm = this
	vm.formInline.storeId = JSON.parse(sessionStorage.getItem('permission')).storeId
	console.log(JSON.parse(sessionStorage.getItem('permission')))
    vm.fetchData(1)
  },
  methods: {
    /**
     * @Description: 获取提现记录列表
     * @author liuChen
     * @date 2020-09-08 13:07
    */
    fetchData(page=1) {
      let vm = this
      vm.table_loading = true
	  if (vm.startTime && this.endTime) {
	  	vm.formInline.orderTimeStart = dateFormat(vm.startTime)
	  	vm.formInline.ordreTimeEnd = dateFormat(vm.endTime)
	  	if (vm.formInline.orderTimeStart > vm.formInline.ordreTimeEnd) {
	  		vm.$message({
	  			type: 'warning',
	  			message: '开始时间不能大于结束时间'
	  		});
	  		return;
	  	}
	  } else {
	  	vm.formInline.orderTimeStart = ''
	  	vm.formInline.ordreTimeEnd = ''
	  }
      // vm.table_loading = true
      vm.pageInfo.pageNum = page
      vm.formInline.pageNum = page
      vm.dataApi.ajax('storeWithdrawList',vm.formInline, res => {
        vm.table_loading = false
        let data = JSON.parse(JSON.stringify(res))
        vm.pageInfo.dtos = data.dtos
        vm.pageInfo.count = data.count
      });
    },
    handleCurrentChange(val) {
      this.fetchData(val);
    },
  }
}
</script>

<style scoped>

</style>
